﻿<Page
    x:Name="pageRoot"
    x:Class="Manhua2.Pages.LocalFileViewPageNew"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Manhua2.Pages"
    xmlns:common="using:Manhua2.Controls"
    xmlns:converter="using:Manhua2.Converter"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    mc:Ignorable="d" Tapped="Page_Tapped" DoubleTapped="Page_DoubleTapped">

    <Page.Resources>
        <converter:RandomAccessStreamToBitmapConverter x:Name="bitmapConverter" />
    </Page.Resources>

    <Grid Style="{StaticResource LayoutRootStyle}">
        <ProgressRing IsActive="{Binding Loading}" Visibility="Visible" Height="50" Width="50" />
        <ScrollViewer x:Name="scrollViewer"
                      HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible"
                      MaxZoomFactor="{Binding MaxScale}" MinZoomFactor="{Binding MinScale}">
            <Image x:Name="image" Stretch="None"
                ImageOpened="Image_ImageOpened"
                ImageFailed="Image_ImageFailed">
            </Image>
        </ScrollViewer>
    </Grid>
    <Page.TopAppBar>
        <AppBar>
            <StackPanel Orientation="Horizontal">
                <Button x:Name="btnGoBack" Style="{StaticResource BackButtonStyle}"
                        Margin="10,0,0,10" AutomationProperties.Name="返回"
                        Click="GoBack"/>
                <TextBlock Text="{Binding ComicTitle}" FontSize="32" Margin="10,5,0,0" Style="{StaticResource HeaderTextStyle}"  />
                <TextBlock Margin="10,12,0,0" Style="{StaticResource SubheaderTextStyle}" Text="当前第" />
                <TextBlock Margin="10,12,0,0" Style="{StaticResource SubheaderTextStyle}" Text="{Binding Page}" />
                <TextBlock Margin="10,12,0,0" Style="{StaticResource SubheaderTextStyle}" Text="页" />
                <TextBlock Margin="10,12,0,0" Style="{StaticResource SubheaderTextStyle}" Text="总共" />
                <TextBlock Margin="10,12,0,0" Style="{StaticResource SubheaderTextStyle}" Text="{Binding TotalPage}" />
                <TextBlock Margin="10,12,0,0" Style="{StaticResource SubheaderTextStyle}" Text="页" />
            </StackPanel>
        </AppBar>
    </Page.TopAppBar>
    <Page.BottomAppBar>
        <AppBar>
            <StackPanel Orientation="Vertical">
                <StackPanel Orientation="Horizontal">
                    <Button x:Name="btnHome" Style="{StaticResource HomeAppBarButtonStyle}"
                        AutomationProperties.Name="主页" Click="btnHome_Click" />
                    <Button x:Name="btnDetail" Style="{StaticResource ViewAllAppBarButtonStyle}"
                        AutomationProperties.Name="打开文件" Click="btnDetail_Click" />

                    <Button x:Name="btnPreviousPage" Style="{StaticResource PreviousAppBarButtonStyle}"
                        AutomationProperties.Name="上一页" Click="btnPreviousPage_Click"/>
                    <Button x:Name="btnNextPage" Style="{StaticResource NextAppBarButtonStyle}"
                        AutomationProperties.Name="下一页" Click="btnNextPage_Click"/>

                    <TextBox x:Name="txtGoPage" Height="0" Width="0" TextAlignment="Center" Text="1" 
                         KeyDown="txtGoPage_KeyDown" />
                    <TextBlock Text="页" Style="{StaticResource SubheaderTextStyle}" VerticalAlignment="Center" 
                           Height="37" Width="34" />
                    <Button x:Name="btnGo" Style="{StaticResource GoAppBarButtonStyle}"
                        AutomationProperties.Name="跳转" Click="btnGo_Click"/>
                </StackPanel>
                <StackPanel Orientation="Horizontal">
                    <Button x:Name="btnZoomIn" Style="{StaticResource ZoomInAppBarButtonStyle}" 
                        AutomationProperties.Name="放大" Click="btnZoomIn_Click" />
                    <Button x:Name="btnZoomOut" Style="{StaticResource ZoomOutAppBarButtonStyle}" 
                        AutomationProperties.Name="缩小" Click="btnZoomOut_Click" />
                    <ToggleSwitch x:Name="direction" OffContent="右方向翻页" OnContent="左方向翻页" />
                    <RadioButton Name="rdoNormal" Content="正常" GroupName="radio" IsChecked="True" Checked="rdoAutoMerge_Checked" />
                    <RadioButton Name="rdoAutoHalf" Content="自动分页" GroupName="radio" Checked="rdoAutoMerge_Checked" />
                    <RadioButton Name="rdoAutoMerge" Content="自动合页" GroupName="radio" Checked="rdoAutoMerge_Checked" />
                </StackPanel>
            </StackPanel>
        </AppBar>
    </Page.BottomAppBar>
</Page>
